<?php

include_once dirname(__DIR__).'/public_models.php';		//加载数据库操作类
class Message_Model extends Public_Models
{
	public function __construct()
	{
		header('Content-Type: text/html; charset=utf-8'); 
		parent::__construct();
	}
	

	//获取游戏消息
	public function getGameMessageInfo()
	{
		$timestamp = time();
		$result = array();
	

        $dealerDB = Game_CONST::DBConst_Name;

		$result['announcement_dict']['is_show'] = 0;
		$result['announcement_dict']['total_sec'] = 0;
		$result['announcement_dict']['content_ary'] = array();
		$announcement_sql = 'select second,content,type from '.Announcement_Detail.' where '.$timestamp.'>=start_time and end_time>'.$timestamp.' and type=0 and is_delete=0 order by data_id asc';
		$announcement_query = $this->getDataBySql($dealerDB,0,$announcement_sql);
		if(DB_CONST::DATA_NONEXISTENT != $announcement_query)
		{
			foreach($announcement_query as $item)
			{
				if($item['content'] != "" && $item['content'] != null && $item['second'] > 0)
				{
					$result['announcement_dict']['is_show'] = 1;
					$result['announcement_dict']['total_sec'] += $item['second'];
					$result['announcement_dict']['content_ary'][] = $item['content'];
				}
			}
		}

		return array('result'=>OPT_CONST::SUCCESS,'data'=>$result,'result_message'=>"游戏消息");
	}
		
	
}